package option;

import book.BookList;

import java.util.Scanner;

public class Borrow implements Ioperate{

    @Override
    public void work(BookList bookList) {
        Scanner scan = new Scanner(System.in);
        System.out.println("输入你要借的书名：");
        String bookName = scan.nextLine();

        //找书
        int size = bookList.getCurSize();
        int i = 0;
        while(i<size){
            if(bookList.getBooks(i).getName().equals(bookName)){
                if(bookList.getBooks(i).isIs_borrow() == false){
                    System.out.println(bookName + "成功被您借出......");
                    bookList.getBooks(i).setIs_borrow(true);
                }else{
                    System.out.println(bookName + "已被人借走，无法借阅.....");
                }
                break;
            }
            i++;
        }

        if(i==size){
            System.out.println("没有这本书");
        }

    }
}
